/*
 *
 *
 */

#ifndef WINDOW_COMMON_H
#define WINDOW_COMMON_H

#include "gkt_debug.h"
#include "gkt_board.h"
#include "gkt_rfid.h"
#include "gkt_window.h"
#include "window_ids.h"
#include "window_voice_combined.h"
#include "window_common_hint_resource.h"
#include "window_dialog.h"
#include "window_input.h"
#include "window_data.h"
#include "window_opcode.h"
#include "window_key.h"

#ifdef GKT_CONFIG_DOOR_TAMPER_ALARM_ENABLE_DEFAULT
#define WINDOW_DOOR_TAMPER_ALARM_ENABLE_DEFAULT	\
	GKT_CONFIG_DOOR_TAMPER_ALARM_ENABLE_DEFAULT
#else
#define WINDOW_DOOR_TAMPER_ALARM_ENABLE_DEFAULT	0
#endif

#define WINDOW_GUEST_ACCESS_TIME_START_HOUR_DEFAULT	0
#define WINDOW_GUEST_ACCESS_TIME_START_MINUTE_DEFAULT	0
#define WINDOW_GUEST_ACCESS_TIME_END_HOUR_DEFAULT	23
#define WINDOW_GUEST_ACCESS_TIME_END_MINUTE_DEFAULT	59

/* auto lock time */
#ifdef GKT_CONFIG_WINDOW_LOCK_AUTO_CLOSE_TIME_MIN
#define WINDOW_LOCK_AUTO_CLOSE_TIME_MIN	\
	GKT_CONFIG_WINDOW_LOCK_AUTO_CLOSE_TIME_MIN
#else
#define WINDOW_LOCK_AUTO_CLOSE_TIME_MIN	2
#endif
#ifdef GKT_CONFIG_WINDOW_LOCK_AUTO_CLOSE_TIME_MAX
#define WINDOW_LOCK_AUTO_CLOSE_TIME_MAX	\
	GKT_CONFIG_WINDOW_LOCK_AUTO_CLOSE_TIME_MAX
#else
#define WINDOW_LOCK_AUTO_CLOSE_TIME_MAX	10
#endif
#ifdef GKT_CONFIG_WINDOW_LOCK_AUTO_CLOSE_TIME_DEFAULT
#define WINDOW_LOCK_AUTO_CLOSE_TIME_DEFAULT	\
	GKT_CONFIG_WINDOW_LOCK_AUTO_CLOSE_TIME_DEFAULT
#else
#define WINDOW_LOCK_AUTO_CLOSE_TIME_DEFAULT	5
#endif

#if defined(GKT_CONFIG_DOOR_LOCK_AUTOMATIC) && GKT_CONFIG_DOOR_LOCK_AUTOMATIC
/* auto double-lock time */
enum {
	WINDOW_AUTO_DOUBLE_LOCK_TIME_ZERO,
	WINDOW_AUTO_DOUBLE_LOCK_TIME_SHORT = 30,
	WINDOW_AUTO_DOUBLE_LOCK_TIME_MIDDLE = 60,
	WINDOW_AUTO_DOUBLE_LOCK_TIME_LONG = 90
};
#endif

enum {
	WINNDOW_SWITCH_ACTION_CLOSE = 0,
	WINNDOW_SWITCH_ACTION_OPEN,
	WINNDOW_SWITCH_ACTION_MAX
};

void window_common_mask(uint32_t mask_bits);
void window_common_mask_all(void);
void window_common_mask_except_keys(uint32_t unmask_keys_bits);
void window_common_mask_except_return(void);
void window_common_mask_except_cancel_ok(void);
void window_common_mask_except_updn_cancel_ok(void);

#if defined(GKT_CONFIG_DEBUG_ENABLE) && GKT_CONFIG_DEBUG_ENABLE
void _window_common_control_key_real_trim(const char *prefix, int enable);
#define window_common_control_key_real_trim(prefix, enable)	\
	_window_common_control_key_real_trim(prefix, enable);
#else
void _window_common_control_key_real_trim(int enable);
#define window_common_control_key_real_trim(prefix, enable)	\
	do {	\
		gkt_unused(prefix);	\
		_window_common_control_key_real_trim(enable);	\
	} while (0)
#endif

void window_common_mask_except_number_repeat_return(
				uint32_t number_end);
void window_common_mask_except_number_return(uint32_t number_end);

enum {
	WINDOW_SELF_INSPECT_KEYPAD = 0,
	WINDOW_SELF_INSPECT_FPSENSOR,
	WINDOW_SELF_INSPECT_RFID,
	WINDOW_SELF_INSPECT_MAX
};
int window_common_self_inspect(uint32_t error_bits[WINDOW_SELF_INSPECT_MAX]);

/* aging test flags */
#define WINDOW_AGING_TEST_F_CARD_TRIGGER	(1U << 0)

/* factory reset mode */
enum {
	WINDOW_FACTORY_RESET_MODE_WITH_CONFIRM = 0,
	WINDOW_FACTORY_RESET_MODE_FORCE,
	WINDOW_FACTORY_RESET_MODE_MAX
};

/* door tamper */
#if defined(GKT_CONFIG_DOOR_TAMPER_ENABLE) \
	&& GKT_CONFIG_DOOR_TAMPER_ENABLE
void window_door_tamper_stop(void);
#else
#define window_door_tamper_stop()	do {} while(0)
#endif

#if	defined(GKT_CONFIG_FACE_ID_ENABLE)	&& (GKT_CONFIG_FACE_ID_ENABLE)
#if	defined(GKT_CONFIG_PROXIMITY_SENSOR_ENABLE)	&& (GKT_CONFIG_PROXIMITY_SENSOR_ENABLE)
void gkt_pr_sensor_handle(void);
#endif
#endif

#if (defined(GKT_CONFIG_VOICE_OUTPUT_HARDWARE_B2206) \
		&& GKT_CONFIG_VOICE_OUTPUT_HARDWARE_B2206) \
	|| (defined(GKT_CONFIG_WINDOW_VOICE_SETTING_SEPRATE_DISABLE) \
		&& GKT_CONFIG_WINDOW_VOICE_SETTING_SEPRATE_DISABLE)
#define WINDOW_VOICE_SETTING_SEPRATE_DISABLE	1
#else
#define WINDOW_VOICE_SETTING_SEPRATE_DISABLE	0
#endif

/* ambient light */
#ifdef GKT_CONFIG_WINDOW_AMBIENT_LIGHT_STATE_DEFAULT
#define WINDOW_AMBIENT_LIGHT_STATE_DEFAULT	\
	GKT_CONFIG_WINDOW_AMBIENT_LIGHT_STATE_DEFAULT
#else
#define WINDOW_AMBIENT_LIGHT_STATE_DEFAULT	1
#endif

#ifdef GKT_CONFIG_WINDOW_AMBIENT_LIGHT_STATE_VERIFY_OK
#define WINDOW_AMBIENT_LIGHT_STATE_VERIFY_OK	\
	GKT_CONFIG_WINDOW_AMBIENT_LIGHT_STATE_VERIFY_OK
#else
#define WINDOW_AMBIENT_LIGHT_STATE_VERIFY_OK	1
#endif

#ifdef GKT_CONFIG_WINDOW_AMBIENT_LIGHT_STATE_VERIFY_FAILED
#define WINDOW_AMBIENT_LIGHT_STATE_VERIFY_FAILED	\
	GKT_CONFIG_WINDOW_AMBIENT_LIGHT_STATE_VERIFY_FAILED
#else
#define WINDOW_AMBIENT_LIGHT_STATE_VERIFY_FAILED	2
#endif

#endif	/* WINDOW_COMMON_H */

